<!--
 * @Author: HeAo
 * @Date: 2021-10-09 11:01:48
 * @LastEditTime: 2021-10-09 11:08:40
 * @LastEditors: HeAo
 * @Description: 
 * @FilePath: \web2103-2105\web2105\3-2-Vue\day02\4-计算属性.html
 * 别乱动！
-->
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="../js/vue.js"></script>
</head>

<body>
  <div id="app">
    {{num1}}
    {{num2}}
    {{ total }}
    {{fmtDate}}
  </div>
  <script>
    let vm = new Vue({
      el: '#app',
      data: {
        num1: 1,
        num2: 2,
        timestamp: 1633748866342
      },
      computed: {
        total() {
          return this.num1 + this.num2
        },
        fmtDate() {
          return new Date(this.timestamp).toLocaleTimeString()
        }
      },
      methods: {
        // toTotal() {
        //   this.total = this.num1 + this.num2
        // }
      },
      created() {
        // this.toTotal()
      }
    })
  </script>
</body>

</html>